/**
 * 预览并批准报告单
 */
const { $fn, $http, $Lazy } = window

const message = $Lazy.file(()=>import('@antd/message'))

const Index = function(option){
	const { spec_num, spec_code, uuid, project_id, audit = 1, test_model = false } = option || {}
	
	if(!$fn.isValid(spec_num)){
		return message.then(f => f.warning('项目有变化，请退回已提交重新审核'))
	}
	
	// 检测中心的取消验证
	if (test_model) {
		let url
		if(project_id){
			url = `preview-audit-report?project_id=${project_id}&spec_num=${spec_num}&spec_code=${spec_code}&audit=${audit}`
		}else{
			url = `preview-audit-report?&spec_num=${spec_num}`
		}
		$fn.pushTo(this, url)
		return
	}
	
	$http.submit(null,'ts-report-card/isreviewreport', { param: {uuid}, loading:false}).then(data=>{
		let url 
		if(project_id){
			url = `preview-audit-report?project_id=${project_id}&spec_num=${spec_num}&spec_code=${spec_code}&audit=${audit}`
		}else{
			url = `preview-audit-report?&spec_num=${spec_num}`
		}
		$fn.pushTo(this, url)
	})
}

export default Index